# -*- coding: utf-8 -*-

'''
author:Cooper
date:2012.5.8

聚划算API
提供聚划算业务相关的接口，目前提供了聚划算团购商品的查询接口

taobao.ju.catitemids.get 根据类目获取商品Id列表
taobao.ju.cities.get 获取当日的生活服务类城市
taobao.ju.cityitems.get 根据城市获取生活服务团商品
taobao.ju.itemids.get 根据终端类型和平台ID获取商品id列表
taobao.ju.items.get 根据商品id列表获取商品列表
taobao.ju.todayitems.get 根据终端类型随机分配一个今天的商品列表
'''

from TopAPI.lib import *
import json

item_data_fields='pic_wide_url,item_id,long_name,short_name,item_url,\
parent_category,child_category,shop_type,pay_postage,original_price,\
pic_url,activity_price,city,item_desc,item_status,\
item_guarantee,discount,platform_id,group_id,seller_id,\
seller_nick,seller_credit,category_id,sold_count,pic_url_from_ic,\
is_lock,current_stock,exist_hold_stock,online_start_time,online_end_time,\
shop_position_list'

class catitem_ids():
	api='taobao.ju.catitemids.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,
		terminal_type='IPHONE',
		platform_id=None,
		parent_categoryid=None,
		child_categoryid=None,
		page_no=None,page_size=None,
		city=None,
		format='json'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		j=json.loads(r.content,r.encoding)
		return j
	pass
class ju_cities():
	api='taobao.ju.cities.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,format='json'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		j=json.loads(r.content,r.encoding)
		return j
	pass
class ju_cityitems():
	api='taobao.ju.cityitems.get'
	def __init__(self):
		self.method=self.api
	def setParams(self,
		city,page_no,page_size,
		format='json'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		d['fields']=item_data_fields
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		j=json.loads(r.content,r.encoding)
		return j
	pass
class itemids():
	api='taobao.ju.itemids.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,
		terminal_type='IPHONE',
		platform_id=None,
		page_no=None,page_size=None,
		city=None,
		format='json'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		j=json.loads(r.content,r.encoding)
		return j
	pass
class items():
	api='taobao.ju.items.get'
	def __init__(self):
		self.method=self.api
	def setParams(self,ids,format='json'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		d['fields']=item_data_fields
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		j=json.loads(r.content,r.encoding)
		return j
	pass
class todayitems():
	api='taobao.ju.todayitems.get'
	def __init__(self):
		self.method=self.api
		self.setParams()
	def setParams(self,
		terminal_type='IPHONE',
		uuid=None,
		format='json'):
		self.__dict__.update(locals())
	def getRes(self):
		d={k:v for k,v in self.__dict__.items() if k!='self' and v!=None}
		d['fields']=item_data_fields
		url=getURL(d)
		return getRes(url)
	def parseData(self):
		r=self.getRes()
		j=json.loads(r.content,r.encoding)
		return j
	pass

def main():
	pass
if __name__=='__main__':
	main()
	pass
